<?php

/*
 * Copyright(c)2016 All rights reserved.
 * @Licenced  http://www.w3.org
 * @Author  liutian<1538731090@qq.com> liutian_jiayi
 * @Create on 2016-6-21 11:27:34
 * @Version 1.0
 */

/**
 * describe of UserModel
 */
namespace Admin\Model;
class UserModel extends \Think\Model{
	//
	public $tableName = "user";
	//设置自动验证规则
	public $_validate = array(
		//账号不能为空
		array("userName", "require", "账号未填写"),
		//密码长度6-15n
		array("password", "6,15", "密码长度应为6-15位", self::MUST_VALIDATE, "length", self::MODEL_INSERT),
		//验证码不能为空
		array("code", "require", "验证码未填写", self::EXISTS_VALIDATE),
		//注册账号时 检查账号的唯一性
//		array("uname", "", "账号已被占用，请重写注册", null, "unique", self::MODEL_INSERT),
		//确认密码 和密码的值一样
		array("repassword", "password", "两次密码输入不一致", self::EXISTS_VALIDATE, "confirm"),
		//昵称不能为空
		array("nickname", "require", "昵称未填写"),
	);
	//设置自动完成规则
	public $_auto = array(
		//密码进行md5加密
		array("password", "md5", self::MODEL_BOTH, "function"),
		//
//		array("password", "setPass", self::MODEL_UPDATE, "callback"),
		//填充创建时间
		array("createtime", "date", self::MODEL_INSERT, "function", array("Y-m-d H:i:s")),
	);
}
